//
//  MCMSecureSettingTableViewCell.m
//  TLYL
//
//  Created by MC on 2017/7/11.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCMSecureSettingTableViewCell.h"

@interface MCMSecureSettingTableViewCell ()

@property (nonatomic,strong)UIView * view_back;
@property (nonatomic,strong)UILabel * lab_Name;
@property (nonatomic,strong)UIView   * view_line;
/*
 * 箭头
 */
@property (nonatomic,strong)UIImageView * imgV_arrow;

@end

@implementation MCMSecureSettingTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=[UIColor clearColor];
    
    
    _view_back=[[UIView alloc]init];
    _view_back.backgroundColor=[UIColor whiteColor];
    [self addSubview:_view_back];
    _view_back.frame=CGRectMake(0, 10, G_SCREENWIDTH, 90);
    
    
    _lab_Name =[[UILabel alloc]init];
    _lab_Name.text=@"(问题1)请选择密保问题";
    _lab_Name.font=[UIFont systemFontOfSize:15];
    _lab_Name.textColor=RGB(100, 100, 100);
    [_view_back  addSubview:_lab_Name];
    
    
   
    
    
    _view_line=[[UIView alloc]init];
    _view_line.backgroundColor=RGB(200, 200, 200);
    [_view_back addSubview:_view_line];
    
    _textField_name =[[UITextField alloc]init];
     [self setTextField:_textField_name WithPlaceholder:@"请输入答案" and:UIKeyboardTypeDefault];
    
    /*
     * 箭头
     */
    _imgV_arrow=[[UIImageView alloc]init];
    [_view_back addSubview:_imgV_arrow];
    _imgV_arrow.image=[UIImage imageNamed:@"MC_Arrow_test"];

    
    [self relayOutConstraints];
}



-(void)relayOutConstraints{
    
    [_lab_Name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_view_back);
        make.left.equalTo(_view_back.mas_left).offset(10);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(G_SCREENWIDTH-20);
        
    }];
    
    [_view_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_lab_Name.mas_bottom);
        make.left.equalTo(_view_back.mas_left).offset(0);
        make.right.equalTo(_view_back.mas_right).offset(0);
        make.height.mas_equalTo(0.5);
    }];
    
    [_textField_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_view_line.mas_bottom);
        make.bottom.equalTo(_view_back);
        make.left.equalTo(_view_back.mas_left).offset(10);
        make.right.equalTo(_view_back.mas_right).offset(-10);
    }];
    
    
    
   
    
    /*
     * 箭头
     */
    [_imgV_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_lab_Name.mas_centerY);
        make.right.equalTo(_view_back.mas_right).offset(-10);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(20);
    }];
    
}
- (BOOL)becomeFirstResponder{
    
    
    return YES;
}
-(void)setDataSource:(id)dataSource{
    
    _dataSource=dataSource;
    _lab_Name.text=dataSource;
    
}

+(CGFloat)computeHeight:(id)info{
    
    return 100;
    
}

-(void)textFieldDidChange:(UITextField *)textField{
    
}


-(void)setTextField:(UITextField*)textField WithPlaceholder:(NSString *)placeholder and:(UIKeyboardType)type{
    textField.placeholder=placeholder;
    textField.borderStyle = UITextBorderStyleNone;
    textField.backgroundColor=[UIColor whiteColor];
    textField.font = [UIFont systemFontOfSize:15];
    textField.textColor = RGB(100, 100, 100);
    textField.textAlignment = NSTextAlignmentLeft;
    textField.returnKeyType = UIReturnKeyDone;
    textField.keyboardType = type;
    [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
    [_view_back addSubview:textField];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
